package com.oromwin.repos.server.response.volume;

import java.io.DataOutputStream;
import java.io.IOException;

import org.apache.commons.logging.Log;

import com.oromwin.repos.common.Logger;
import com.oromwin.repos.common.ReposException;
import com.oromwin.repos.common.helper.IOHelper;
import com.oromwin.repos.data.VolumeTable;
import com.oromwin.repos.server.response.NormalResponse;

public class InfoVolumeResponse extends NormalResponse {
    private Log log = Logger.getLog(InfoVolumeResponse.class);
    private VolumeTable volumeTable = null;
    
    public InfoVolumeResponse(boolean result, String description, VolumeTable vTable) {
        Result = result;
        Description = description;
        volumeTable = vTable;
    }
    
    public void send(DataOutputStream dos) throws ReposException {
        try {
            dos.writeBoolean(Result);
            IOHelper.writeUTF8(dos, Description.toString());
            IOHelper.writeUTF8(dos, volumeTable.getVolumeId());
            IOHelper.writeUTF8(dos, volumeTable.getVolumeName());
            dos.writeBoolean(volumeTable.getVolumeStatus());
            IOHelper.writeUTF8(dos, volumeTable.getVolumeCreateDate());
            IOHelper.writeUTF8(dos, volumeTable.getVolumeUpdateDate());
        } catch (IOException e) {
            throw ReposException.create(log, e);
        }
    }
}
